<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/9/15
 * Time: 23:30
 */
?>


<script>
    $(function(){
        var prescription = $('#prescription');
        $(window).resize(function(){
            prescription.treegrid('resize', {
                width:function(){
                    return document.body.clientWidth;
                },
                height:function(){
                    return document.body.clientHeight;
                }
            });
        });

        prescription.treegrid({
            url:'<?php echo CController::createUrl('prescription/getPerscriptionHistory',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>',
            method:'get',
            fitColumns:true,
            rownumbers:true,
            idField:'id',
            treeField:'date',
            fit:true,
            striped:true,
            remoteSort:false,
            singleSelect:true,
            nowrap:false,
            border:false,
            toolbar: '#toolbar-prescription',
            onDblClickRow :function(rowIndex){
                if(rowIndex.iconCls!=null){
                    
                    addPatientTab('历史处方','<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=prescription/FindPerscription&pk_outpatient_prescription_id='+rowIndex.pre_id+'&pk_outpatient_id=<?php echo $pk_outpatient_id?>','icon-ehr');
                }
            }
        });
    });

    function refresh(){
        $('#prescription').treegrid('load',{
            url: '<?php echo CController::createUrl('prescription/getPerscriptionHistory',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>'
        });
    }

</script>

<table id="prescription" class="easyui-treegrid">
    <thead>
    <tr>
        <th data-options="field:'date'">病历时间</th>
    </tr>
    </thead>
</table>
<div id="toolbar-prescription">
    <table style="border-spacing:0">
        <tr style="margin-bottom: 5px;">
            <td>
                <div class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addPatientTab('添加处方','<?php echo CController::createUrl('prescription/addPatientPrescription',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>','icon-prescription')">添加处方</div>
                <div class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="refresh();">刷新列表</div>
            </td>
        </tr>
    </table>
</div>

